#ifndef GX_STRING_BUILDER_H
#define GX_STRING_BUILDER_H
#include "GxString.h"

namespace GxLibBasic
{
	class StringBuilder
	{
	private:
		int FBufInc;
		wchar_t * FStr;
		int FLen;
		int FPtr;
	public:
		StringBuilder(int len);
		~StringBuilder();
		void SetBufferIncrement(int _inc);
		void Alloc(int len);
		void Clear();
		void Erase(int len)
		{
			if (FPtr >= len)
				FPtr -= len;
			FStr[FPtr] = 0;
		}
		void WriteChar(wchar_t ch);
		void WriteString(const wchar_t * str);
		void WriteString(const wchar_t * str, int len);
		void WriteString(String str);
		int Count();
		wchar_t* GetStrPtr();
		String MoveToString()
		{
			gxStringData * data = new gxStringData();
			data->AllocLength = FLen;
			data->Length = FPtr;
			data->Data = FStr;
			data->RefCount = 1;
			data->MBChar = 0;
			FStr = 0;
			FPtr = 0;
			FLen = 0;
			return String(data);
		}
	};
}
#endif